package com.ddc.study.net.response;

import com.google.gson.annotations.SerializedName;

/**
 * Created on 2018/3/28.
 *
 * @author lshun
 * @version 1.0
 */
public abstract class IResponse {
    @SerializedName("errorCode")
    private int mErrorCode;
    @SerializedName("errorMsg")
    private String mErrorMsg;

    public int getErrorCode() {
        return mErrorCode;
    }

    public void setErrorCode(int errorCode) {
        mErrorCode = errorCode;
    }

    public String getErrorMsg() {
        return mErrorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        mErrorMsg = errorMsg;
    }

    public boolean isSuccess() {
        return mErrorCode >= 0;
    }

    /**
     * 判断身份是否过期
     *
     * @return 身份过期返回true
     */
    public boolean isIdentityExpiry() {
        return mErrorCode < 0 && mErrorMsg != null && mErrorMsg.contains("登录");
    }
}
